
export function killMyPid() {
    const pid = android.os.Process.myPid();
    const activityManager = context.getSystemService(context.ACTIVITY_SERVICE);
    const processList = activityManager.getRunningAppProcesses();
    const length = processList.length;
    for (let i = 0; i < length; i++) {
        const processInfo = processList.get(i);
        const processInfoPid = processInfo.pid;
        const processInfoUid = processInfo.uid;
        // org.autojs.autoxjs.v6
        const processInfoName = processInfo.processName;
        // org.autojs.autoxjs.v6
        const processInfoPkgList = processInfo.pkgList;
        if (processInfoPid === pid) {
            android.os.Process.killProcess(processInfoPid)
        }
    }
}

export function killPid(pkg: string) {
    const activityManager = context.getSystemService(context.ACTIVITY_SERVICE);
    const processList = activityManager.getRunningAppProcesses();
    const length = processList.length;
    for (let i = 0; i < length; i++) {
        const processInfo = processList.get(i);
        const processInfoPid = processInfo.pid;
        const processInfoUid = processInfo.uid;
        // org.autojs.autoxjs.v6
        const processInfoName: string = processInfo.processName;
        log(processInfoName)
        // org.autojs.autoxjs.v6
        const processInfoPkgList = processInfo.pkgList;
        if (processInfoName.includes(pkg)) {
            android.os.Process.killProcess(processInfoPid)
            continue;
        }
    }
}